home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / WIN / VB_DB / PROFIT.ZIP / INGGRMNT.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1993-03-19  |  11.4 KB  |  435 lines

  1. VERSION 2.00
  2. Begin Form IngGrMnt 
  3.    BackColor       =   &H00E0FFFF&
  4.    Caption         =   "Ingredient Group File Maintenance"
  5.    Height          =   1875
  6.    Icon            =   INGGRMNT.FRX:0000
  7.    Left            =   1950
  8.    LinkMode        =   1  'Source
  9.    LinkTopic       =   "IngGrMnt"
  10.    MaxButton       =   0   'False
  11.    MDIChild        =   -1  'True
  12.    ScaleHeight     =   1470
  13.    ScaleWidth      =   6225
  14.    Top             =   2805
  15.    Width           =   6345
  16.    Begin CommandButton CmdClose 
  17.       Caption         =   "&Close"
  18.       Height          =   375
  19.       Left            =   5280
  20.       TabIndex        =   10
  21.       Top             =   960
  22.       Width           =   855
  23.    End
  24.    Begin CommandButton CmdCancel 
  25.       Cancel          =   -1  'True
  26.       Caption         =   "Cancel"
  27.       FontBold        =   0   'False
  28.       FontItalic      =   0   'False
  29.       FontName        =   "MS Sans Serif"
  30.       FontSize        =   8.25
  31.       FontStrikethru  =   0   'False
  32.       FontUnderline   =   0   'False
  33.       Height          =   375
  34.       Left            =   4440
  35.       TabIndex        =   9
  36.       Top             =   960
  37.       Width           =   855
  38.    End
  39.    Begin CommandButton CmdDelete 
  40.       Caption         =   "&Delete"
  41.       FontBold        =   0   'False
  42.       FontItalic      =   0   'False
  43.       FontName        =   "MS Sans Serif"
  44.       FontSize        =   8.25
  45.       FontStrikethru  =   0   'False
  46.       FontUnderline   =   0   'False
  47.       Height          =   375
  48.       Left            =   3480
  49.       TabIndex        =   8
  50.       Top             =   960
  51.       Width           =   855
  52.    End
  53.    Begin CommandButton CmdUpdate 
  54.       Caption         =   "&Update"
  55.       FontBold        =   0   'False
  56.       FontItalic      =   0   'False
  57.       FontName        =   "MS Sans Serif"
  58.       FontSize        =   8.25
  59.       FontStrikethru  =   0   'False
  60.       FontUnderline   =   0   'False
  61.       Height          =   375
  62.       Left            =   2640
  63.       TabIndex        =   7
  64.       Top             =   960
  65.       Width           =   855
  66.    End
  67.    Begin CommandButton CmdAdd 
  68.       Caption         =   "&Add"
  69.       FontBold        =   0   'False
  70.       FontItalic      =   0   'False
  71.       FontName        =   "MS Sans Serif"
  72.       FontSize        =   8.25
  73.       FontStrikethru  =   0   'False
  74.       FontUnderline   =   0   'False
  75.       Height          =   375
  76.       Left            =   1800
  77.       TabIndex        =   6
  78.       Top             =   960
  79.       Width           =   855
  80.    End
  81.    Begin CommandButton CmdNext 
  82.       BackColor       =   &H00FFFFFF&
  83.       Caption         =   "&Next"
  84.       FontBold        =   0   'False
  85.       FontItalic      =   0   'False
  86.       FontName        =   "MS Sans Serif"
  87.       FontSize        =   8.25
  88.       FontStrikethru  =   0   'False
  89.       FontUnderline   =   0   'False
  90.       Height          =   375
  91.       Left            =   840
  92.       TabIndex        =   5
  93.       Top             =   960
  94.       Width           =   735
  95.    End
  96.    Begin CommandButton CmdPrevious 
  97.       Caption         =   "&Previous"
  98.       FontBold        =   0   'False
  99.       FontItalic      =   0   'False
  100.       FontName        =   "MS Sans Serif"
  101.       FontSize        =   8.25
  102.       FontStrikethru  =   0   'False
  103.       FontUnderline   =   0   'False
  104.       Height          =   375
  105.       Left            =   120
  106.       TabIndex        =   4
  107.       Top             =   960
  108.       Width           =   735
  109.    End
  110.    Begin TextBox Text3 
  111.       Height          =   375
  112.       Left            =   2160
  113.       TabIndex        =   3
  114.       Top             =   480
  115.       Width           =   3975
  116.    End
  117.    Begin TextBox Text2 
  118.       Height          =   375
  119.       Left            =   2160
  120.       TabIndex        =   1
  121.       Top             =   120
  122.       Width           =   615
  123.    End
  124.    Begin Label LblDesc 
  125.       Alignment       =   1  'Right Justify
  126.       BackColor       =   &H00E0FFFF&
  127.       Caption         =   "D&escription:"
  128.       Height          =   255
  129.       Left            =   120
  130.       TabIndex        =   2
  131.       Top             =   480
  132.       Width           =   1815
  133.    End
  134.    Begin Label LblKey 
  135.       Alignment       =   1  'Right Justify
  136.       BackColor       =   &H00E0FFFF&
  137.       Caption         =   "&Group No:"
  138.       Height          =   255
  139.       Left            =   240
  140.       TabIndex        =   0
  141.       Top             =   120
  142.       Width           =   1695
  143.    End
  144. '*************************************************************
  145. '*  Form Name:  IngGrMnt                                     *
  146. '*  Performs file maintenance to Ingredient group file.          *
  147. '*************************************************************
  148.   Dim EntryMode As String * 1
  149.   Dim FieldError As Integer
  150.   Dim DeactivatedKey As String
  151. Sub ClearAllFields ()
  152.   EntryMode = "N"
  153.   Text2.Text = ""
  154.   Text3.Text = ""
  155.   Text2.SetFocus
  156.   SetCmdFlags
  157. End Sub
  158. Sub ClearDataFields ()
  159.   Text3.Text = ""
  160. End Sub
  161. Sub CmdAdd_Click ()
  162.     ErrorCheckFields
  163.     MoveFieldsToRecord
  164.     If Not FieldError Then
  165.     WriteIngGroup
  166.     Select Case IngGroupSt%
  167.       Case 0
  168.         ClearAllFields
  169.       Case 3
  170.         MsgIngGroupNotOpen
  171.       Case 5
  172.         Msg$ = "Ingredient Group already on file."
  173.         T1% = MsgBox(Msg$, 0, "Note")
  174.         Text2.SetFocus
  175.       Case Else
  176.         MsgUnknownIngGroupError
  177.     End Select
  178.     End If
  179. End Sub
  180. Sub CmdCancel_Click ()
  181.   If EntryMode = "C" Then
  182.     Text2.Text = IngGroupSaveRec.IngGroup
  183.     Text3.Text = RTrim$(IngGroupSaveRec.IngGroupDesc)
  184.     Text3.SetFocus
  185.     Text3.SelStart = Len(Text3.Text)
  186.     EntryMode = "U"
  187.     SetCmdFlags
  188.   Else
  189.     ClearAllFields
  190.   End If
  191. End Sub
  192. Sub CmdClose_Click ()
  193.   Unload IngGrMnt
  194. End Sub
  195. Sub CmdDelete_Click ()
  196.     Msg$ = "Are you sure?"
  197.     TI% = MsgBox(Msg$, 260, "Delete?")
  198.     If TI% = 6 Then
  199.       DeleteIngGroup
  200.       Select Case IngGroupSt%
  201.     Case 0
  202.       ClearAllFields
  203.     Case 8
  204.       Msg$ = "Record must be found before you can delete."
  205.       Beep
  206.       T1% = MsgBox(Msg$, 0, "Warning!")
  207.     Case 80
  208.       Msg$ = "This record updated since read. Reread and try again."
  209.       Beep
  210.       T1% = MsgBox(Msg$, 0, "Not Deleted!")
  211.     Case Else
  212.       Msg$ = "Ingredient Group not deleted.  Status = " + Str$(IngGroupSt%)
  213.       Beep
  214.       T1% = MsgBox(Msg$, 0, "Warning!")
  215.       End Select
  216.     End If
  217. End Sub
  218. Sub CmdNext_Click ()
  219.   NextIngGroup
  220.   Select Case IngGroupSt%
  221.     Case 0
  222.       DisplayDataFields
  223.     Case 3
  224.       MsgIngGroupNotOpen
  225.     Case 8
  226.       FirstIngGroup
  227.       If IngGroupSt% <> 0 Then
  228.     MsgUnknownIngGroupError
  229.       Else
  230.     DisplayDataFields
  231.       End If
  232.     Case 9
  233.       Msg$ = "End of Ingredient Group file."
  234.       T1% = MsgBox(Msg$, 0, "Note")
  235.     Case Else
  236.       MsgUnknownIngGroupError
  237.   End Select
  238. End Sub
  239. Sub CmdPrevious_Click ()
  240.   PreviousIngGroup
  241.   Select Case IngGroupSt%
  242.     Case 0
  243.       DisplayDataFields
  244.     Case 3
  245.       MsgIngGroupNotOpen
  246.     Case 8
  247.       FirstIngGroup
  248.       If IngGroupSt% <> 0 Then
  249.     MsgUnknownIngGroupError
  250.       Else
  251.     DisplayDataFields
  252.       End If
  253.     Case 9
  254.       Msg$ = "Beginning of Ingredient Group file."
  255.       T1% = MsgBox(Msg$, 0, "Note")
  256.     Case Else
  257.       MsgUnknownIngGroupError
  258.   End Select
  259. End Sub
  260. Sub CmdUpdate_Click ()
  261.     EntryMode = "C"
  262.     IngGroupRec.IngGroupDesc = Text3.Text
  263.     UpdateIngGroup
  264.     Select Case IngGroupSt%
  265.       Case 0
  266.     EntryMode = "N"
  267.     ClearAllFields
  268.       Case 3
  269.     MsgIngGroupNotOpen
  270.       Case 5
  271.     Msg$ = "Ingredient Group duplicate on file."
  272.     T1% = MsgBox(Msg$, 0, "Note")
  273.       Case 8
  274.     Msg$ = "Update only works on found records."
  275.     T1% = MsgBox(Msg$, 0, "Note")
  276.       Case 80
  277.     Msg$ = "This record updated since read. Reread and try again."
  278.     T1% = MsgBox(Msg$, 0, "Warning!")
  279.       Case Else
  280.     MsgUnknownIngGroupError
  281.     End Select
  282. End Sub
  283. Sub DisplayDataFields ()
  284.     IngGroupSaveRec = IngGroupRec
  285.     Text2.Text = IngGroupRec.IngGroup
  286.     Text3.Text = RTrim$(IngGroupRec.IngGroupDesc)
  287.     Text3.SetFocus
  288.     EntryMode = "U"
  289.     SetCmdFlags
  290. End Sub
  291. Sub ErrorCheckFields ()
  292.   FieldError = False
  293.   If LTrim$(RTrim$(Text2.Text)) = "" Then
  294.     Msg$ = "Ingredient Group number is required."
  295.     T1% = MsgBox(Msg$, 0, "Note")
  296.     FieldError = True
  297.     Text2.SetFocus
  298.     Exit Sub
  299.   End If
  300.   If LTrim$(RTrim$(Text3.Text)) = "" Then
  301.     Msg$ = "You must have a description."
  302.     T1% = MsgBox(Msg$, 0, "Note")
  303.     FieldError = True
  304.     Text3.SetFocus
  305.     Exit Sub
  306.   End If
  307. End Sub
  308. Sub Form_Activate ()
  309.    If DeactivatedKey <> "" Then
  310.      IngGroupRec.IngGroup = DeactivatedKey
  311.      ReadIngGroup
  312.    End If
  313. End Sub
  314. Sub Form_Deactivate ()
  315.     DeactivatedKey = IngGroupRec.IngGroup
  316. End Sub
  317. Sub Form_Load ()
  318.     DeactivatedKey = ""
  319.     Top = DeliMain.Top + 1320
  320.     Left = DeliMain.Left + 1320
  321.     Height = 1875
  322.     Width = 6345
  323.     EntryMode = "N"
  324.     SetCmdFlags
  325. End Sub
  326. Sub MoveFieldsToRecord ()
  327.     IngGroupRec.IngGroup = String$(4 - Len(Text2.Text), "0") + Text2.Text
  328.     IngGroupRec.IngGroupDesc = Text3.Text
  329. End Sub
  330. Sub SetCmdFlags ()
  331.   Select Case EntryMode
  332.     Case "N"
  333.       CmdPrevious.Enabled = True
  334.       CmdNext.Enabled = True
  335.       CmdCancel.Enabled = False
  336.       CmdAdd.Enabled = True
  337.       CmdUpdate.Enabled = False
  338.       CmdDelete.Enabled = False
  339.     Case "U"
  340.       CmdPrevious.Enabled = True
  341.       CmdNext.Enabled = True
  342.       CmdCancel.Enabled = False
  343.       CmdAdd.Enabled = False
  344.       CmdUpdate.Enabled = True
  345.       CmdDelete.Enabled = True
  346.     Case "C"
  347.       CmdPrevious.Enabled = True
  348.       CmdNext.Enabled = True
  349.       CmdCancel.Enabled = True
  350.       CmdAdd.Enabled = False
  351.       CmdUpdate.Enabled = True
  352.       CmdDelete.Enabled = False
  353.     Case Else
  354.       Msg$ = "Undefined Entry Mode Flag - " + EntryMode + "."
  355.       T1% = MsgBox(Msg$, 0, "Warning!")
  356.   End Select
  357. End Sub
  358. Sub Text2_Change ()
  359.   If EntryMode = "U" Then
  360.     EntryMode = "C"
  361.     SetCmdFlags
  362.   End If
  363. End Sub
  364. Sub Text2_GotFocus ()
  365.   Text2.SelStart = 0
  366.   Text2.SelLength = Len(Text2.Text)
  367. End Sub
  368. Sub Text2_KeyDown (KeyCode As Integer, Shift As Integer)
  369.     If KeyCode = KEY_PAGE_UP Then
  370.     CmdPrevious_Click
  371.     End If
  372.     If KeyCode = KEY_PAGE_DOWN Then
  373.     CmdNext_Click
  374.     End If
  375. End Sub
  376. Sub Text2_KeyPress (KeyAscii As Integer)
  377.   If KeyAscii = 13 Then
  378.     KeyAscii = 0
  379.     Text3.SetFocus
  380.   ElseIf Chr$(KeyAscii) = "-" Then
  381.     KeyAscii = 0
  382.     Beep
  383.   Else
  384.     IntKP Text2, 4, KeyAscii
  385.   End If
  386. End Sub
  387. Sub Text2_LostFocus ()
  388.   If Text2.Text <> "" Then
  389.     EntryMode = "N"
  390.     IngGroupRec.IngGroup = String$(4 - Len(Text2.Text), "0") + Text2.Text
  391.     ReadIngGroup
  392.     Select Case IngGroupSt%
  393.       Case 0
  394.     DisplayDataFields
  395.       Case 3
  396.     MsgIngGroupNotOpen
  397.       Case 4
  398.     ClearDataFields
  399.       Case Else
  400.     MsgUnknownIngGroupError
  401.     End Select
  402.     SetCmdFlags
  403.   End If
  404. End Sub
  405. Sub Text3_Change ()
  406.   If EntryMode = "U" Then
  407.     EntryMode = "C"
  408.     SetCmdFlags
  409.   End If
  410. End Sub
  411. Sub Text3_GotFocus ()
  412.   Text3.SelStart = 0
  413.   Text3.SelLength = Len(Text3.Text)
  414. End Sub
  415. Sub Text3_KeyDown (KeyCode As Integer, Shift As Integer)
  416.     If KeyCode = KEY_PAGE_UP Then
  417.     CmdPrevious_Click
  418.     End If
  419.     If KeyCode = KEY_PAGE_DOWN Then
  420.     CmdNext_Click
  421.     End If
  422. End Sub
  423. Sub Text3_KeyPress (KeyAscii As Integer)
  424.   If KeyAscii = 13 Then
  425.     KeyAscii = 0
  426.     If CmdUpdate.Enabled = True Then
  427.       CmdUpdate.SetFocus
  428.     Else
  429.       CmdAdd.SetFocus
  430.     End If
  431.   Else
  432.     UCStrKP Text3, 30, KeyAscii
  433.   End If
  434. End Sub
  435.